<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html>
<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
                template="/template.xhtml"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns="http://www.w3.org/1999/xhtml"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:p="http://primefaces.org/ui">

    <ui:define name="title">
        HelpDeskRu:AdminZone
    </ui:define>

    <ui:define name="top_menu">
        <ui:include src="/admin/main_menu.xhtml"/>
    </ui:define>
    
    
    <ui:define name="content">
        
        <h:form id="form">

            

            <p:dataTable value="#{organizationController.listAllOrganization}" var="item" 
                         emptyMessage="" rowKey="#{item.id}" editable="true">
                
                <f:facet name="header">
                    
                    <h:outputText value="#{prop['admin.organizations.header']}"/>
                    <br/>
                    <div align="left">
                        <p:commandButton value="#{prop['admin.organizations.addNewOrg']}"
                                         actionListener="#{organizationController.addNewOrg}"
                                         update="@form"
                                         icon="ui-icon-plus"/>                        
                    </div>
                </f:facet>


                <p:column headerText="Id">
                    <h:outputText value="#{item.id}" />
                </p:column>

                <p:column headerText="#{prop['admin.organizations.dataTableheaderText']}">

                    <p:cellEditor>

                        <f:facet name="output">
                            <h:outputText value="#{item.name}" />
                        </f:facet>

                        <f:facet name="input">
                            <h:inputText value="#{item.name}" size="15"/>
                        </f:facet>

                    </p:cellEditor>

                </p:column>
            
                <p:column>
                    <p:rowEditor />
                </p:column>


                <p:column> 
                    
                    <p:commandLink  value="#{prop['admin.organizations.deleteOrg']}"
                                    update=":deleteOrgForm:deleteOrgPanel"
                                    oncomplete="deleteOrgConfirmDialog.show()">
                        <f:setPropertyActionListener target="#{organizationController.currentOrg}" 
                                                     value="#{item}"/>
                    </p:commandLink>
                </p:column>


                <f:facet name="footer">
                    <div align="left">
                        <p:commandButton value="#{prop['admin.organizations.saveAll']}" actionListener="#{organizationController.saveAll}"
                                         update="@form"
                                         icon="ui-icon-disk"/>
                        
                    </div>
                </f:facet>
                
            </p:dataTable>            
            
            
            
            

        </h:form>

        

        <h:form id="deleteOrgForm">
        
            <p:outputPanel id="deleteOrgPanel">
                
                <p:confirmDialog message="#{prop['admin.organizations.deleteOrgPanel.message']} #{organizationController.currentOrg}?"
                                header="#{prop['admin.organizations.deleteOrgPanel.header']}" severity="alert"
                                widgetVar="deleteOrgConfirmDialog">

                    <p:commandButton value="#{prop['admin.yes']}" 
                                     actionListener="#{organizationController.deleteOrg}"
                                     action="/admin/organizations"
                                     update=":form" 
                                     oncomplete="deleteOrgConfirmDialog.hide()"/>

                    <p:commandButton value="#{prop['admin.no']}" 
                                     onclick="deleteOrgConfirmDialog.hide()" 
                                     type="button" />

                </p:confirmDialog>

            </p:outputPanel>
            
        </h:form>
                
        
        
    </ui:define>
    
</ui:composition>